Using the CtlHTML Control Library

Do the following steps to add the CtlHTML Control Library to a program:


      BOOL CMyDialog::OnInitDialog() 
      {
         CDialog::OnInitDialog();
      
         CWnd *pWnd;

         // Note: Must set edit box text before calling CtlHTMLSubclassDialog, otherwise 
         //       these controls will not be subclassed
         if ((pWnd = GetDlgItem(IDC_EDITBOX)) != 0)
            pWnd->SetWindowText("<HTML>This is HTML text.</HTML>");

         // init HTML controls
         CtlHTMLSubclassDialog(m_hWnd);
         return TRUE;
      }

      void CMainFrame::OnSysColorChange ()
      {
         CFrameWnd::OnSysColorChange ();
         CtlHTMLSetColors();
      }

      void CMainFrame::OnFontChange ()
      {
         CFrameWnd::OnFontChange ();
         HTMLResetFonts();
      }

      void CMyDialog::OnActivate (UINT nState, CWnd* pWndOther, BOOL bMinimized)
      {
         CDialog::OnActivate(nState, pWndOther, bMinimized);
         CtlHTMLDialogEnable(m_hWnd, nState != WA_INACTIVE);
      }

      BOOL CMyApp::InitInstance()
      {
         ...
         // init CtlHTML Control Library - set the fonts
         HTMLSetFont(_T("Tahoma"), 8);
         ...
         return TRUE;
      }

      BOOL CMyApp::InitInstance()
      {
         ...
         // init CtlHTML Control Library - necessary for static link library version
         InitCtlHtml(AfxGetInstanceHandle());
         ...
         return TRUE;
      }

      int CMyApp::ExitInstance() 
      {
         // exit the CtlHTML Control Library - necessary for static link library version
         ExitCtlHtml();
         return CWinApp::ExitInstance();
      }

That's it. That's all you need to do.

Debugging the CtlHTML Control Library

The following is a list of the most common mistakes made when using the CtlHTML Control Library. If the control library doesn't work as you expect, chances are you have made one of the following mistakes:

Copyright ⌐ 1999, Windmill Point Software. All Rights Reserved.
Last Updated May 19, 1999